<?php

class BlogCommentTable extends Doctrine_Table
{
  public function retrieveBackendList(Doctrine_Query $q)
  {
    $q->leftJoin($q->getRootAlias().'.Post p');
    
    return $q;
  }

  public function retrieveLastActiveComments($lang, $limit = 10)
  {
    return $this->
      createQuery('c')->
      leftJoin('c.Post p')->
      where('p.lang = ?', $lang)->
      andWhere('p.is_published = ?', true)->
      orderBy('c.created_at desc')->
      limit($lang)->
      execute()
    ;
  }
}
